package cn.monkey.chat.server.connect.chat.state.group;

import cn.monkey.chat.server.connect.chat.ChatExchange;
import cn.monkey.chat.server.proto.Package;
import cn.monkey.state.core.StateContext;

import java.util.*;

public class ChatContext implements StateContext {
    private final Map<String, ChatExchange> chatExchanges;
    private final List<Package> messageRecord;
    //private final ChatMessageRepository chatMessageRepository;

    public ChatContext() {
        this.chatExchanges = new HashMap<>();
        this.messageRecord = new ArrayList<>();
    }

    public void add(ChatExchange chatExchange) {
        this.chatExchanges.put(chatExchange.id(), chatExchange);
    }

    public void remove(String id) {
        this.chatExchanges.remove(id);
    }

    public Collection<ChatExchange> getAllExchange() {
        return this.chatExchanges.values();
    }

    public ChatExchange getExchange(String id) {
        return this.chatExchanges.get(id);
    }


    public void addMessage(Package pkg) {
        this.messageRecord.add(pkg);
    }
}
